package com.examonline.utils.result;


import java.io.Serializable;

public class ResultUtil implements Serializable {

    /**
     * 不带参数的成功
     * @return
     */
    public static Result success(){
        Result result=new Result();
        result.setCode(ResultEnum.SUCCESS.getCode());
        result.setMsg(ResultEnum.SUCCESS.getMsg());
        result.setData(null);
        return result;
    }

    /**
     *  参数的成功
     * @param data 返回的数据
     * @return
     */
    public static Result success(Object data){
        Result result=new Result();
        result.setStatus(ResultEnum.SUCCESS.getCode());
        result.setMsg(ResultEnum.SUCCESS.getMsg());
        result.setData(data);
        return result;
    }

    /**
     * 返回错误信息
     * @param resultEnum
     * @return
     */
    public static Result error(ResultEnum resultEnum){
        Result result=new Result();
        result.setStatus(resultEnum.getStatus());
        result.setCode(resultEnum.getCode());
        result.setMsg(resultEnum.getMsg());
        return result;
    }

}
